Jim's
Tutorials

Fall 2018
course
site

Nate's Work Chapters 2 and 3

I read chapters 2 and 3 and explored generating random bits. The chapter was clear that random bits generated using the Mersenne Twister algorithm, which is used in python, ruby and a bunch of others as the default generator, generates randomly distributed bytes that are not cryptographically secure because they are entirely deterministic. By doing some bitwise operations you can determine the next output given a certain number of outputs. This code code on github can predict the values after seeing 624 values from an MT algorithm:

https://gist.github.com/Rhomboid/b1a882c70b7a1901efa9

I tried graphing some functions using a jupyter notebook and matplotlib. The algorithm is good at producing evenly distributed points, so just graphing the output isn't very illuminating. I successfully generated a bunch of arrays of random numbers and plotted them in 2d graphs successively. I got hung up on an error trying to graph them in 3d space. This code created a valid graph:

ax = plt.axes(projection='3d')

# Data for three-dimensional scattered points
data = [random.random() for i in range(999)]
zdata = [random.random() for i in range(1000)]
xdata = [random.random() for i in range(1000)]
ydata = [random.random() for i in range(1000)]
ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap='Blues');

but this code did not:

ax = plt.axes(projection='3d')

# Data for three-dimensional scattered points
data = [random.random() for i in range(999)]
zdata = [data for i in range(0, 999, 3)]
xdata = [data for i in range(1, 999, 3)]
ydata = [data for i in range(2, 999, 3)]
ax.scatter3D(xdata, ydata, zdata, c=zdata, cmap='Blues');

My error message was:

AttributeError: 'list' object has no attribute 'shape'

At first I was just hitting this error and tried making working code as close as possible to the code I wanted that created a valid graph. In both cases the data put into the graph are arrays of floats from 0 to 1. I don't think the second graph would be particularly more illuminating but it would be nice if it worked. Graphing something like the derivative between x and y in z-space might show a more useful pattern if the output can be determined from 624 successive example outputs, but I didn't get that far. Below are some screenshots.

In chapter 3 they talked about provably secure and insecure cryptographic schemes that often build off of perviously proven algorithms. I used ssl to generate a symmetric key like this:

>>openssl rand 16 -hex
95fe00b9be243fd3ae4242f0ab7907dd

The book also talked about how asymmetric keys were protected, how some were generated directly from passwords, and some were generated by a PRNG and then password protected locally, which can generally be considered more secure because they aren't as vulnerable to poor password strength. IE: if your information is encrypted based on a key generated from your password, if an attacker knows the algorithm they can try a number of common passwords to decrypt your message, where if your key is stored and protected locally by a password, it is harder for them to gain access to testing the password.

>> openssl genrsa -aes128 4096
Generating RSA private key, 4096 bit long modulus
............++
........................................................++
e is 65537 (0x10001)
Enter pass phrase:
Verifying - Enter pass phrase:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,07CFB3CBE8948D6154251E620AD974F5

sZfPJTONkwP+X39DEKJlxv4x7thoZIPENPHEHyT0ANvlvh70NyvtuTi7zHfeecl8
yQHLu6BH5GEXpqfuZb+d+FeKbMdPi396tplPK/gLRcxlLnyUrLdtOXW5/C8DZuh4
8EHzYabrRo/1QhkwI+dayeSxw2GJQMJQer1MO/191fYlaDjlj1EFzjoETIHcjQPn
0u5uQkkv1i1Fyn3sDyX5k5B7bulR33a+x5ibqEzGbGlIqQb5aFRi9C9EB6Gzj8+G
8xR9MxmbDbgivmRLRwOM+l3hoIKGk5RMljTlsSIUEzSo95U2e6+1yFnedyYwQDOv
FXewO8fsBI6tjQ90J1WiY/mFd10spjxDB3OPPwfru7vqHtpyjU6hJJDWXUF85pVr
RmBxDiujKXAl94xV4/5oWcXjFgewGXqFhK3KpraBd+gNzWdweWC1jeCgOZsS9Prv
9WXTMEf5AiIao2P6Hn9UjxvfjJSboB2MyVJYPH8cIi9mavqTBHWMmTGHagua7aXv
wO253F8OxnJB5qewz20a0DLE5vXY60Rn3Qn9vQLvAUdjWTmnA9qbXMMhalel27Wg
xNuvDM9T6HDyews34qoQdCi5C/c8iiPzXmtpf0chbCm4M9RHBJoPIyZdUp9EHG21
6H3nPuBK4gdZTFV3D1AvBrrVLXswlaQ22b26WAR9bCnmV3W0qp0qhRYvog4wqII+
QqzONgRhNLY3FLyjiK26iXHhxGBDYzBHixO8WoZ9a0aa/DHKktXdaLM6YRVxhNRB
rFZFRf7VnCQt4uT+RMbF+tSUJt4Cp28B6K3h3+mLm6cjSYWuIOz9C82ZwrvJIaCO
Ro0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fMrdlA83Sx9vmTx
0KG/mFthHyTaypd8OTeYQAB2f/SwmSLOoAOkZx0i4ulnn9sxfhuG0E9UQ72Vr/fH
7EsLh+wScP+lBClNPQbyQy7tg5e+jeFNClokIOmoxxn3gmLOTD/SWkoVcBT3r8G2
ebdj1g7UD2T+pWvKrs8I1ATt3MNxedx41fPEvPGX22IBrPoQC89YdlAztEAnraMD
-----END RSA PRIVATE KEY-----

attachments [paper clip]

  last modified size
TXT Screen_Shot_2018-09-14_at_12.26.28_PM.png Sun May 05 2024 01:15 pm 216K
TXT Screen_Shot_2018-09-14_at_12.27.11_PM.png Sun May 05 2024 01:15 pm 523K